<template>
  <div class="packageOrdersList">
    <div class="table-big">
      <div class="formGroup">
        <div class="tips"><i class="el-icon-warning-outline"></i>报表文件只保存7天，请及时下载</div>
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="130px" class="">
          <el-form-item prop="userName2">
            <el-select v-model="queryParams.userName2" size="small" filterable placeholder="任务状态" @change="handleQuery">
              <el-option
                v-for="item in statusList"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="userName2">
            <el-date-picker
              size="small"
              v-model="timeRange"
              style="width: 240px"
              value-format="yyyy-MM-dd"
              type="daterange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :picker-options="pickerOptions"
            ></el-date-picker>
          </el-form-item>
          <el-button plain size="small">刷新</el-button>
        </el-form>
      </div>
      <div class="tableAnalysis">
        <el-table
          :data="tableDataList"
          ref="customerMgtList"
        >
          <el-table-column
            :label="item.label"
            align="center"
            v-for="(item, index) in tableColumns"
            :key="index"
            :prop="item.key"
            :min-width="item.minWidth ? item.minWidth : ``"
            :fixed="item.fixed ? item.fixed : false"
            :show-overflow-tooltip="true"
          >
            <!--用于表格自定义-->
            <template slot="header" v-if="item.showHeaderTip">
              <div>
                {{ item.label }}
                <el-tooltip effect="dark" :content="item.showHeaderTip" placement="top">
                  <span><i class="el-icon-question"></i></span>
                </el-tooltip>
              </div>
            </template>
            <template slot-scope="scope">
              <div v-if="item.key=='status'" class="status">
                <span :class="scope.row.status==0? `glay`:scope.row.status==1?`green`:red"></span>
                {{ scope.row.status }}
              </div>
              <div v-else>{{ scope.row[item.key] }}</div>
            </template>
          </el-table-column>
          <el-table-column
            fixed="right"
            label="操作"
            align="center"
            width="120">
            <template slot-scope="scope">
              <el-button v-hasPermi="['system:report:download']" @click="handleDel(scope.row)" type="text" size="small">下载</el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>
  </div>
</template>
<script>
import {listUser} from "@/api/system/user";
import {getTime} from "@/utils";

export default {
  name: "reportCenterList",
  components: {
  },
  data() {
    return {
      showAddOrEditMsg: false,
      queryParams: {},
      timeRange:[],
      statusList: [
        {
          value: '1',
          label: '已完成'
        }, {
          value: '2',
          label: '进行中'
        }, {
          value: '3',
          label: '失败'
        }
      ],
      tableHeight: 600,
      tableColumns: [
        {key: 'name', label: `任务提交时间`, visible: true, minWidth: 150, fixed: true},
        {key: 'status', label: `任务状态`, visible: true, minWidth: 150, fixed: false,},
        {key: 'type', label: `文件名称`, visible: true, minWidth: 200,},
        {key: 'type', label: `文件过期时间`, visible: true, minWidth: 200,},
        {key: 'type', label: `操作者`, visible: true, minWidth: 200,},
      ],
      tableDataList: [],
      total: 8, // 表格的总条数
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > new Date().getTime()
        }
      },
    }
  },
  watch: {},
  created() {
    //this.getList();
    this.tableDataList = [];
    for (let i = 0; i < 3; i++) {
      let obj = {
        name: '2023-12-12',
        mobile: 0,
        msg: '加油',
        status:0,
      }
      this.tableDataList.push(obj);
    }
  },
  methods: {
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.tableDataList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    handleDel(row) {
    },
    getMsg(row) {
      this.showAddOrEditMsg=true;
    },
  },
}
</script>


<style scoped lang="scss">
.timeType {
  display: flex;
  align-items: center;
  margin-right: 10px;

  li {
    border: 1px solid #eee;
    height: 32px;
    margin: 0;
    padding: 0 15px;
    list-style: none;
    cursor: pointer;

    &.active {
      border-color: #2d8cf0;
      color: #2d8cf0;
    }
  }
}

.time-big {
  display: flex;
  align-items: center;
}

.formGroup {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  position: relative;
  .tips{
    position: absolute;
    right: 0px;
    top: 10px;
    color: rgba(0, 0, 0, 0.45);
    i {
      color: #f8ac59;
      margin-right: 10px;
    }
  }
}

.center-title {
  height: 30px;
  display: flex;
  align-items: center;

  span {
    content: "";
    width: 4px;
    height: 14px;
    background-color: #3070ff;
    display: block;
    margin-right: 5px;
  }
}

.tableAnalysis {
  padding-bottom: 20px;
  position: relative;

  .center-title {
    margin-bottom: 20px;
  }

  .exportData {
    position: absolute;
    right: 0px;
    top: 0px;

  }
}

.packageOrdersList {
  padding: 16px;
}

.table-big {
  background: #fff;
  padding: 10px;
}

.search {
  display: flex;

  ::v-deep.el-input__inner {
    border-right: none !important;
    border-radius: 4px 0px 0px 0px;
  }

  ::v-deep .el-button--default {
    border-radius: 0px 4px 4px 0px;
    padding: 0px 10px;
  }
}


.number-big {
  padding: 12px;
  background: #fff;
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  border-radius: 4px;

  .number {
    margin-right: 30px;
  }

}

.qrCode {
  width: 130px;
  margin: auto;
  display: flex;
  justify-content: center;
  flex-direction: column;

  .qrCode-img {
    width: 120px;
    margin-bottom: 20px;
  }

  img {
    width: 120px;
    margin-bottom: 20px;
  }
}

.title {
  font-size: 14px;
  display: flex;

  img {
    width: 26px;
    height: 26px;
  }
}

.msg {
  i {
    font-size: 16px;
    color:#3b74ff;
    cursor: pointer;
  }
}
.status {
  span {
    width: 9px;
    height: 9px;
    display: inline-block;
    border-radius: 100%;

    &.green {
      background: #00DD33;
    }

    &.red {
      background: red;
    }

    &.glay {
      background: #8C8C8C;
    }
  }
}
</style>
